#ifndef __HASHMAP_H__
#define __HASHMAP_H__

#include "IHashable.h"

namespace hash_map{
	template<class Key,class Value>
	class HashMap{
	private:
		struct Item{
			Key key;
			Value value;
			Item(Key k,Value v):key(k),value(v){}
		};
		const static Item* deleted;
	public:
		class Iterator
		{
		public:
			Iterator (const HashMap& hash_map);
			bool operator!= (const Iterator& other) const; 
			Key operator* () const;
			const Iterator& operator++ ();
		private:
			int getNext(int x)const;
			const HashMap& map;
			int position;
		};
	

		HashMap();
		~HashMap();
		bool insert(Key key, Value value);
		bool remove(Key key);
		bool contains(Key key)const;
		
		Value get(Key key)const;
		Value operator[](Key key)const;
		
		Iterator begin()const;
		Iterator end()const;
	private:
		int find(Key key, bool inserting=false)const;
		inline int hash(int main, int secondary)const;
		void rehash(int new_capacity);

		static const int start_capacity=8;
		Item** values;
		int capacity;
		int size;
	};
}

#endif __HASHMAP_H__